<?php

class ClassStructure_Mixin_PhpEnvironment {
	
    const MEMORY_LIMIT = 'memory_limit';
    const MAX_EXECUTION_TIME = 'max_execution_time';
    
    private $arr_environment = array();
    private $arr_ini_values = array();
    
	/**
	 * Constructor: sets object properties during object construction
	 * 
	 * @access public
	 * @param mixed $mix_properties An array or object of properties.
	 * @return object
	 */
	public function __construct() {
	}
    
    public function defineEnvironment($arr_options = array()) {
        
        $arr_keys = array(
            self::MEMORY_LIMIT,
            self::MAX_EXECUTION_TIME
        );
        
        foreach($arr_keys as $str_key) {
            if(isset($arr_options[$str_key])) {
                $this->arr_environment[$str_key] = $arr_options[$str_key];
            }
        }

    }
    
	public function setupEnvironment() {
		
        foreach($this->arr_environment as $str_key => $str_value) {
            $this->arr_ini_values[$str_key] = ini_get($str_key);
            ini_set($str_key, $str_value);
        }
        
	}

    public function revertEnvironment() {
        
        foreach($this->arr_ini_values as $str_key => $str_value) {
            ini_set($str_key, $str_value);
        }
        
    }
		
}
